package service.impl;

import dao.UserDao;
import dao.impl.UserDaoImpl;
import factory.ObjectFactory;
import service.UserService;

/**
 * Author:shixiaojun@itany.com
 * Date:2022/3/4 10:26
 * Version:1.0-SNAPSHOT
 */
public class UserServiceImpl implements UserService {

//    private UserDao userDao = new UserDaoImpl();
//    private UserDao userDao = (UserDao) ObjectFactory.getObject();
    // 在Java中,想要为某一个属性进行赋值
    // 要么通过set方法,要么通过构造函数
    // Spring想要为对应属性赋值,也必须符合Java的机制
    private UserDao userDao;
    private String name;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public void register() {
        System.out.println(name+"正在执行注册操作");
        userDao.insert();
    }

    @Override
    public void login() {
        System.out.println(name+"正在执行登录操作");
        userDao.select();
    }
}
